import Vue from 'vue'
import Router from 'vue-router'
const Login = () => import('../components/Login')
const Mobile = () => import('../components/Mobile')
const HomePage = () => import('../components/HomePage')
const MyActivity = () => import('../components/MyActivity')
const ActivityHouse = () => import('../components/ActivityHouse')
const ActivityDiscover = () => import('../components/ActivityDiscover')
const MyAuth = () => import('../components/MyAuth')
const ActivityDetail = () => import('../components/ActivityDetail')
const ActivityContent = () => import('../components/ActivityContent')
const Team = () => import('../components/Team')
const TeamUser = () => import('../components/TeamUser')
const Student = () => import('../components/Student')
const UserInfo = () => import('../components/UserInfo')

Vue.use(Router)
//防止跳转相同路由报错
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};
export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/userInfo',
      name: 'userInfo',
      component: UserInfo
    },
    {
      path: '/mobile',
      name: 'mobile',
      component: Mobile
    },
    {
      path: '/homePage',
      component: HomePage,
      //有默认子路由，父路由要去掉name，不然会有警告
      children: [
        //默认显示路径
        {
          path: '',
          redirect: 'activityHouse'
        },
        {
          path: 'activityDiscover',
          component: ActivityDiscover
        },
        {
          path: 'myActivity',
          component: MyActivity
        },
        {
          path: 'activityContent',
          component: ActivityContent
        },
        {
          path: 'activityHouse',
          component: ActivityHouse
        },
        {
          path: 'myAuth',
          component: MyAuth
        },
        {
          path: 'activityDetail',
          component: ActivityDetail
        },
        {
          path: 'team',
          component: Team
        },
        {
          path: 'teamUser',
          component: TeamUser
        },
        {
          path: 'student',
          component: Student
        }
      ]
    },
  ]
})
